#!/bin/sh

#copy latest netcare-agent
sudo scp -r  $2@$1:$3/netcare/linux_32/netcare-agent /usr/bin/
#write init
echo "#!/bin/bash
### BEGIN INIT INFO
# provides              netcare_init
# Required-Start:	$"network" $"remote_fs" haldaemon
# Should-Start:		
# Required-Stop:	$"network" $"remote_fs" haldaemon
# Should-Stop:		
# Default-Start:	2 3 5
# Default-Stop:	
# description:          netcare
### END INIT INFO
start(){   
/usr/bin/netcare-agent &
echo  "service Netcare is started..."  
}     
stop(){   
killall netcare-agent
echo  "service Netcare is stoped..."  
}   
  
case $"1" in   
start)   
start   
;;   
stop)   
stop   
;;   
*)   
echo "error choice ! please input start or stop";;   
esac   
exit 0" > /etc/init.d/netcare-agent
chmod +x /etc/init.d/netcare-agent #add netcare to run

#create connect in different run level
sudo chkconfig --add netcare-agent

#start netcare
sudo cp /root/Documents/netcare/netcare_version /usr/bin
sudo service netcare-agent start &

exit 1
